function get_enviroment(proxy_array) {
    for (var i = 0; i < proxy_array.length; i++) {
        handler = '{\n' +
            '    get: function(target, property, receiver) {\n' +
            '        console.log("方法:", "get  ", "对象:", ' +
            '"' + proxy_array[i] + '" ,' +
            '"  属性:", property, ' +
            '"  属性类型:", ' + 'typeof property, ' +
            // '"  属性值:", ' + 'target[property], ' +
            '"  属性值类型:", typeof target[property]);\n' +
            '        return target[property];\n' +
            '    },\n' +
            '    set: function(target, property, value, receiver) {\n' +
            '        console.log("方法:", "set  ", "对象:", ' +
            '"' + proxy_array[i] + '" ,' +
            '"  属性:", property, ' +
            '"  属性类型:", ' + 'typeof property, ' +
            // '"  属性值:", ' + 'target[property], ' +
            '"  属性值类型:", typeof target[property]);\n' +
            '        return Reflect.set(...arguments);\n' +
            '    }\n' +
            '}'
        eval('try{\n' + proxy_array[i] + ';\n'
            + proxy_array[i] + '=new Proxy(' + proxy_array[i] + ', ' + handler + ')}catch (e) {\n' + proxy_array[i] + '={};\n'
            + proxy_array[i] + '=new Proxy(' + proxy_array[i] + ', ' + handler + ')}')
    }
}
function watch(obj, name) {
    const isProxyActive = Symbol("isProxyActive");
    return new Proxy(obj, {
        get: function (target, property, receiver) {
            try {
                const value = target[property];
                if (value === undefined && !receiver[isProxyActive]) {
                    const protoChainNeeded = !Object.getPrototypeOf(target).hasOwnProperty(property);
                    const descriptor = Object.getOwnPropertyDescriptor(target, property) || {};
                    const toStringDesc = descriptor.toString || (descriptor.get && descriptor.get.toString());
                    console.log(`${name}.${property} 读取: ${String(value)} (${typeof value}), 补原型链: ${protoChainNeeded}, toString: ${toStringDesc || '无'}`);
                }
            } catch (e) { }
            return target[property];
        },
        set: (target, property, newValue, receiver) => {
            try {
                if (!receiver[isProxyActive]) {
                    const displayValue = String(newValue);
                    if (displayValue.length <= 50) {
                        const protoChainNeeded = !Object.getPrototypeOf(target).hasOwnProperty(property);
                        const descriptor = Object.getOwnPropertyDescriptor(target, property) || {};
                        const toStringDesc = descriptor.toString || (descriptor.get && descriptor.get.toString());
                        console.log(`${name}.${property} 设置: ${displayValue} (${typeof newValue}), 补原型链: ${protoChainNeeded}, toString: ${toStringDesc || '无'}`);
                    }
                }
            } catch (e) { }
            return Reflect.set(target, property, newValue, receiver);
        }
    });
}
proxy_array = ['window', 'document', 'location', 'navigator', 'history', 'screen']

// ------------- 补环境开始  ------------
let is_logging = true

_log = console.log

function v_log() {
    if (is_logging) {
        _log(...arguments)
    }
}

!(function () {
    "use strict";
    const $toString = Function.toString;
    const myFunction_toString_symbol = Symbol('('.concat('', ')_', (Math.random() + '').toString(36)));
    const mytoString = function () {
        return typeof this == 'function' && this[myFunction_toString_symbol] || $toString.call(this);
    };
    function set_native(func, key, value) {
        Object.defineProperty(func, key, {
            "enumerable": false,
            "configurable": true,
            "writable": true,
            "value": value
        })
    };
    delete Function.prototype['toString'];
    set_native(Function.prototype, "toString", mytoString);
    set_native(Function.prototype.toString, myFunction_toString_symbol, "function toString() { [native code] }");
    this.func_set_native = function (func) {
        set_native(func, myFunction_toString_symbol, `function ${myFunction_toString_symbol, func.name || ''}() { [native code] }`)
    }
}).call(this);


Window = function () {
}
window = self = parent = top = globalThis;
window.__proto__ = Window.prototype // "try{return (window instanceof Window);}catch(e){}"
delete global;
delete GLOBAL;
delete root;

window.top = window;

var _null = function () {
    v_log("--arguments--", ...arguments)
};

window.outerHeight = 1080
window.outerWidth = 1920
window.Math = Math;
window.Date = Date;
window.parseInt = parseInt;
window.addEventListener = _null
window.attachEvent = undefined
HTMLFormElement = function () {
    this.init();
    return this.json;
}
window.HTMLFormElement = HTMLFormElement
window.openDatabase = function openDatabase(dbname, version, description, dbsize, dbcallback) {
    debugger;
    return {
        version: version
    }
};
window.chrome = {
    "app": {
        "isInstalled": false,
        "InstallState": {
            "DISABLED": "disabled",
            "INSTALLED": "installed",
            "NOT_INSTALLED": "not_installed"
        },
        "RunningState": {
            "CANNOT_RUN": "cannot_run",
            "READY_TO_RUN": "ready_to_run",
            "RUNNING": "running"
        }
    }
}
window.onbeforeunload = function _$8a(_$hM) { if (_$Sq) { _$IY(new _$Bd(_$BJ, {}, _$BS(_$hM[_$Mi(_$zu[41])]))); _$CQ(); } }

function getImageDate() {
    return 'function getImageData() { [native code] }'
}

ctx = {
    rect: function (x, y, w, h) {
        console.log("canvas rect: ", x, y, w, h);
    },
    getContextAttributes: function () {
        console.log('ctx getAttributes')
        return ctx_attr;
    },
    isPointInPath: function (path, x, y) {
        console.log('ctx isPointInPath: ', path, x, y);
        return false;
    },
    fillRect: function (x, y, w, h) {
        console.log('ctx fillRect: ', x, y, w, h);
    },
    fillText: function (text, x, y) {
        console.log('ctx fillText: ', text, x, y);
    },
    beginPath: function () { },
    arc: function (x, y, radius, start, end) {
        console.log('ctx arc: ', x, y, radius, start, end);
    },
    closePath: function () { },
    fill: function (path) {
        console.log('ctx fill: ', path);
    },
}
CanvasRenderingContext2D = {
    canvas: {},
    direction: "ltr",
    fillStyle: "#000000",
    filter: "none",
    font: "10px sans-serif",
    fontKerning: "auto",
    fontStretch: "normal",
    fontVariantCaps: "normal",
    globalAlpha: 1,
    globalCompositeOperation: "source-over",
    imageSmoothingEnabled: true,
    imageSmoothingQuality: "low",
    letterSpacing: "0px",
    lineCap: "butt",
    lineDashOffset: 0,
    lineJoin: "miter",
    lineWidth: 1,
    miterLimit: 10,
    shadowBlur: 0,
    shadowColor: "rgba(0, 0, 0, 0)",
    shadowOffsetX: 0,
    shadowOffsetY: 0,
    strokeStyle: "#000000",
    textAlign: "start",
    textBaseline: "alphabetic",
    textRendering: "auto",
    wordSpacing: "0px",
    getImageDate: getImageDate
}
_ddd = {
    get: function () { }
}
_canvas = {
    getContext: function (arg) {
        if (arg === "2d") {
            return CanvasRenderingContext2D
        }
        return ctx
    },
    toDataURL: function () {
        return ''
    },
}
window.canvas = _canvas

Navigator = function Navigator() {
}
Navigator.prototype = {
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0',
    languages: ['zh-CN', 'zh'],
    language: 'zh-CN',
    appVersion: '5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0',
    webdriver: false,
    appCodeName: "Mozilla",
    vendor: 'Google Inc.',
}
window.navigator = {};
window.navigator.__proto__ = Navigator.prototype

Location = function () {
}
Location.prototype = {
    "ancestorOrigins": {},
    "href": "https://www.popmart.com/us/search/LABUBU?page=2",
    "origin": "https://www.popmart.com",
    "protocol": "https:",
    "host": "www.popmart.com",
    "hostname": "www.popmart.com",
    "port": "",
    "pathname": "/us/search/LABUBU",
    "search": "?page=2",
    "hash": ""
}

window.location = new Location;

History = function History() {
}
History.prototype.back = function back() {
}
window.history = new History

Screen = function () {
}
Screen.prototype = {
    availWidth: 1920,
    availHeight: 1080,
    availLeft: 0,
    availTop: 0,
    height: 960,
    width: 1707
}
window.screen = new Screen

FengNewAll = function FengNewAll() { }
const HTMLAllCollection = function HTMLAllCollection() { };
HTMLAllCollection.name = "HTMLAllCollection";
HTMLAllCollection.length = 0;
HTMLAllCollection.prototype = Array.prototype;
HTMLAllCollection.prototype.constructor = HTMLAllCollection;
const myObject = {};
myObject.all = new FengNewAll();
Object.setPrototypeOf(myObject.all, HTMLAllCollection.prototype);
for (let i = 0; i < 5; i++) {
    myObject.all.push(i)
}
Document = function Document() {
}
Document.prototype = {
    getElementById: function getElementById() {
        _log(arguments)
    },
    createElement: function (a) {
        _log(arguments)
    },
    getElementsByTagName: function (arg) {
        console.log("getElementsByTagName-->", arguments)

    },
    addEventListener: _null,
    appendChild: _null,
    removeChild: _null,
    documentElement: {},
    characterSet: 'UTF-8',
    charset: 'UTF-8'
}
Object.defineProperty(Document.prototype, "all", {
    get: function () {
        return myObject.all;
    },
    configurable: true,
    enumerable: true
})

window.document = new Document;
Object.setPrototypeOf(document, Document.prototype);

localStorage = {

    getItem: function (str) {
        if (str in this) {
            return this[str]
        } else
            return null
    },
    setItem: function (key, value) {
        // debugger
        this[key] = value
    }
}

localStorage = watch(localStorage, 'localStorage')

window.location = location

get_enviroment(proxy_array);

debugger
